LOAD DATA

Add variables to the existing dataset

15 minute volume takes the VMT for each time bin and divides by the length of the segment. Unit: Vehicles per mile. Speed is the segment length divided by the travel time ( * 60). Unit: Miles per hour. Hourly_Flow is the 15 minute volume multipled by 4 and divided by the number of lanes. Unit: Vehicles per hour. Density is the Hourly Flow divided by speed. Unit: Vehicles per hour.

We also create a variable that measures the delay type experienced by the segment. Weather (snow) events and crashes were tracked for the time period. If the segment experiences a weather event and a crash, weather will be the controlling delay type.

Check the dataset for outliers by plottling all of the travel time obsevations for each segment.

We see three significant outliers in Segment 9. Upon inspection of the dataset, these travel times were observed during a crash incident.

## Using 'Count' as value column. Use 'value.var' to override

Percentile Bin and Free Flow

We will break down the dataset into each delay type and then further into percentiles.

The percentiles choosen are 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95.

For each quantile a travel time quantile is calculated. We also want to calculate a Free Floew Speed for each quantile.

The Free Flow speeds were calcuated using the 95th percentile speeds.

MAP

FREE FLOW PLOTS

Segment 1

Segment 2

Segment 3

Segment 4

Segment 5

Segment 6

Segment 7

Segment 8

Segment 9

DENSITY vs TT

A look at the Density vs travel time plots. A generic smooting function has been added.

Segment 1

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 1 & Density_bin > 199)) %>%
  filter(!(Segment == 1 & Delay_type == 'None' & Density_bin > 100)) %>%
  filter(!(Segment == 1 & Delay_type == 'Crash' & Density_bin > 45))

Segment 2

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 2 & Delay_type == 'Crash' & Density_bin > 100)) %>%
  filter(!(Segment == 2 & Delay_type == 'Weather' & Density_bin > 81))
## Warning: Removed 7 rows containing non-finite values (stat_smooth).

Segment 3

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 3 & Delay_type == 'None' & Density_bin > 90)) %>%
  filter(!(Segment == 3 & Delay_type == 'Crash' & Density_bin > 101)) 

Segment 4

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 4 & Delay_type == 'None' & Density_bin > 59)) %>%
  filter(!(Segment == 4 & Delay_type == 'None' & Density_bin == 50)) %>%
  filter(!(Segment == 4 & Delay_type == 'Weather' & Density_bin > 40)) %>%
  filter(!(Segment == 4 & Delay_type == 'Crash' & Density_bin == 48)) 

Segment 5

## Warning: Removed 7 rows containing non-finite values (stat_smooth).

Segment 6

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 6 & Delay_type == 'None' & Density_bin > 70)) 

Segment 7

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 7 & Delay_type == 'Weather' & Density_bin > 59)) %>%
  filter(!(Segment == 7 & Delay_type == 'None' & Density_bin > 46)) %>%
  filter(!(Segment == 7 & Delay_type == 'Crash' & Density_bin > 46))

Segment 8

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 8 & Delay_type == 'None' & Density_bin > 80)) %>%
  filter(!(Segment == 8 & Delay_type == 'Crash' & Density_bin == 80))

Segment 9

Rel_bin <- Rel_bin %>%
  filter(!(Segment == 9 & Delay_type == 'Weather' & Density_bin > 40)) %>%
  filter(!(Segment == 9 & Delay_type == 'None' & Density_bin > 80)) %>%
  filter(!(Segment == 9 & Delay_type == 'Crash' & Density_bin > 38))

DENSITY vs FLOW

Below are the Flow vs Density plots for each condition.

Vertical and horizontal dashed lines indicate the Congested Density and Flow points. This values were manually determined by visually inspecting these plots.

Segment 1

Segment 2

Segment 3

Segment 4

Segment 5

Segment 6

Rel_bin <- Rel_bin %>%
  # filter(!(Segment == 1 & Delay_type == 'Weather' & Density_bin > 300)) %>%
  filter(!(Segment == 6 & Density_bin > 59))

Segment 7

Segment 8

Segment 9

DEMAND

Calculate Demand and DC.

Rel_bin <- merge(Rel_bin,dens_flow_tab,
                 by = c('Delay_type','quantiles', 'Segment')) %>%
  mutate(Demand = ifelse(Density_bin <= Density_cong, Flow,
                         ifelse(Density_bin >= Density_cong & Flow <= Flow_cong,
                                Flow_cong + (Flow_cong - Flow),
                                Flow)),
         DC = Demand/Flow_cong) 

TTI vs DEMAND

A look at the Density vs travel time plots. A generic smooting function has been added.

Segment 1

Segment 2

Segment 3

Segment 4

Segment 5

Segment 6

Segment 7

Segment 8

Segment 9

Prediction

The below code is used to develop the model based on the relationship between TTI and DC.

q <- 50
br <- 0.95
q <- paste(q, '%', sep ='')

sample_data <- Rel_bin %>%
  filter(Segment == 3, Delay_type == 'None', quantiles == q, !is.na(DC)) %>%
  select(DC, TTI)

formulaExp <- as.formula(TTI ~(DC <= br) + (DC > br) * ( mu * (DC ^ b)))
b <- 3
mu <- 1.5
# preview(formulaExp, data = sample_data, start = list(mu, b))
# formulaExp <- as.formula(TTI ~(DC <= br) + (DC > br) * ( mu * (DC ^ b)))

sample_nls <- nls(formulaExp, data = sample_data, start = list(mu = 1.5, b = 3))
plotfit(sample_nls, smooth = TRUE)

Prediction Results

Prediction Segment 1

plot_predict(1)

Prediction Segment 2

plot_predict(2)

Prediction Segment 3

plot_predict(3)

Prediction Segment 4

plot_predict(4)

Prediction Segment 5

plot_predict(5)

Prediction Segment 6

plot_predict(6)

Prediction Segment 7

plot_predict(7)

Prediction Segment 8

plot_predict(8)

Prediction Segment 9

plot_predict(9)

HEATMAP

SEGMENT 1

TT_heat(Rel_p,1, model = FALSE)

TT_heat(Rel_p,1, model = TRUE)

SEGMENT 2

TT_heat(Rel_p,2, FALSE)

TT_heat(Rel_p,2, TRUE)

SEGMENT 3

TT_heat(Rel_p,3, FALSE)

TT_heat(Rel_p,3, TRUE)

SEGMENT 4

TT_heat(Rel_p,4, FALSE)

TT_heat(Rel_p,4, TRUE)

SEGMENT 5

TT_heat(Rel_p,5, FALSE)

TT_heat(Rel_p,5, TRUE)

SEGMENT 6

TT_heat(Rel_p,6, FALSE)

TT_heat(Rel_p,6, TRUE)

SEGMENT 7

TT_heat(Rel_p,7, FALSE)

TT_heat(Rel_p,7, TRUE)

SEGMENT 8

TT_heat(Rel_p,8, FALSE)

TT_heat(Rel_p,8, TRUE)

SEGMENT 9

TT_heat(Rel_p,9, FALSE)

TT_heat(Rel_p,9, TRUE)